'''
Created on 2019年3月25日

@author: Administrator
'''
from collections import __getattr__

class Person(object):
    '''
    classdocs
    '''
    sex = '男'
    
    def __init__(self, name,age,weight):
        '''构造函数'''
        self.name = name
        self._age = age
        self.__weight = weight
    
    def __str__(self, *args, **kwargs):
        return object.__str__(self, *args, **kwargs)
    
    def get_weight(self):
        return self.__weight
    
    @classmethod
    def get_age(self):
        return self.sex
    
    '''
        @classmethod  相当于java中statix
        @property  实例化调用方法名后不需要()
    '''
    @property
    def getInfo(self):
#         return '我的名字叫'+self.name+",今年"+self._age+"岁，体重"+self.__weight
        print('我的名字叫%s,今年%s岁，体重%s' % (self.name,self._age,self.__weight))
     
    '''回收对象'''  
    def __del__(self):
        '''析构函数'''
        
    def __getattribute__(self,name):
        return super(Person,self).__getattribute__(name)
    
    def __setattr__(self, name,value):
        self.__dict__[name] = value;
    
if __name__ == '__main__':
    person = Person('hhl','23','75')
    person.__setattr__('sex', '女')
    print(person.__str__())
    print(dir(person))
    print(person.name)
    print(person._age)
    print(person.get_weight())
    print(person._Person__weight)
    print(person.getInfo)
    print(Person.get_age())
    
    